 
use std::any::Any;
use std::sync::Arc;
use async_trait::async_trait;

use crate::core::manifest::ContributionKeywordDefinition;
use crate::core::plugin::RigPlugin;
use crate::core::services::context::ActivateContext;

use super::keyword_impl::StreamsImplement;


/// Streams 插件的结构体
pub struct StreamsPlugin {
    service_context: Arc<StreamsImplement>,
}

impl StreamsPlugin {
    pub fn new() -> Self {
        Self {
            service_context: Arc::new(StreamsImplement::new()),
        }
    }
}

#[async_trait]
impl RigPlugin for StreamsPlugin {
    async fn activate(&mut self, _ctx: &ActivateContext) -> Option<Arc<dyn Any + Send + Sync>> {
        println!("Streams plugin activated.");
        None
    }

    async fn deactivate(&mut self, _ctx: &ActivateContext) {
        println!("Streams plugin deactivated.");
    }

    fn get_contribution_keyword(
        &self,
        _keyword: &ContributionKeywordDefinition,
        _ctx: &ActivateContext,
    ) -> Option<Box<dyn Any + Send + Sync>> {
        Some(Box::new(self.service_context.clone()))
    }

    fn get_context(&self) -> Option<Arc<dyn Any + Send + Sync>> {
        Some(self.service_context.clone() as Arc<dyn Any + Send + Sync>)
    }
}